<?php
if (!defined('APP_PATH')) {
	define('APP_PATH', $_SERVER['DOCUMENT_ROOT']."/bdACPA");
}
require_once(APP_PATH.'/required.php');
$comboPheno = "";
header("Content-type:text/xml");
echo("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");

$out = "<items>";
$out .=	"<item type='settings' position='label-left' labelWidth='auto' inputWidth='120'/>";
$out .= "<item type='radio' name='typeRecherche' labelWidth='auto' value='region' position='label-right' label='Visualiser une région' checked='true'>";
$out .= "<item type='fieldset' width='450' label='Par position'>";
$out .= "	<item type='input' name='parGene' label='Nom de gène (ex : MAPT)' value=''/>";
$out .= "	<item type='combo' name='parBande' width='150' >";
$out .= "<option value='0' text='Toutes les bandes' selected='true'/>";
$bandes =	$BANDE_DAO->rechercher_bande();
foreach ($bandes as $bande){
		$out .= "		<option value='".intval($bande->idbande)."' text='".remove_carspeciaux($bande->chromosome.$bande->bras.$bande->numero)."' />";
}
$out .= "	</item>";
$out .= "	<item type='combo' name='parChromosome' width='150' >";
$out .= "<option value='0' text='Tous les chromosomes' selected='true'/>";
$out .= "		<option value='1' text='1' />";
$out .= "		<option value='2' text='2' />";
$out .= "		<option value='3' text='3' />";
$out .= "		<option value='4' text='4' />";
$out .= "		<option value='5' text='5' />";
$out .= "		<option value='6' text='6' />";
$out .= "		<option value='7' text='7' />";
$out .= "		<option value='8' text='8' />";
$out .= "		<option value='9' text='9' />";
$out .= "		<option value='10' text='10' />";
$out .= "		<option value='11' text='11' />";
$out .= "		<option value='12' text='12' />";
$out .= "		<option value='13' text='13' />";
$out .= "		<option value='14' text='14' />";
$out .= "		<option value='15' text='15' />";
$out .= "		<option value='16' text='16' />";
$out .= "		<option value='17' text='17' />";
$out .= "		<option value='18' text='18' />";
$out .= "		<option value='19' text='19' />";
$out .= "		<option value='20' text='20' />";
$out .= "		<option value='21' text='21' />";
$out .= "		<option value='22' text='22' />";
$out .= "		<option value='X' text='X' />";
$out .= "		<option value='Y' text='Y' />";
$out .= "	</item>";
$out .= "	<item type='input' name='parPosition' label='Position (ex : chr7:71890181..72690180)' value=''/>";
$out .= "</item>";
if (isset($utilisateur)){
	$out .= "<item type='fieldset' width='450' label='Filtrer les CNV à afficher par'>";
$out .= "			<item type='combo' name='parMarque' label='Par marque de la puce' validate='NotEmpty' readonly='1'>";
$marques = $MARQUEPUCE_DAO->rechercher_marque_puce();
$out .= "				<option value='0' text='à définir'/>";
foreach ($marques as $marque)
{
	$out .= "			<option value='".intval($marque->idmarquepuce)."' text='".remove_carspeciaux($marque->libelle)."'/>";
}
$out .= "			</item>";	
	
$out .= "	<item type='combo' width='400' name='parModele' label='Modèle de puce' readonly='1'/>";
// $out .= "	<item type='combo' width='400' name='parPhenotype' label='Phénotype de la personne' comboType='checkbox' >";
// $phenos = $PHENOTYPE_DAO->rechercher_phenotype_combo();
// foreach ($phenos as $pheno)
// 	{
// 	$comboPheno .= "			<option value='".intval($pheno["idphenotype"])."' text='".remove_carspeciaux($pheno["pere"])."-".remove_carspeciaux($pheno["libelle"])."'/>";
// 	}
// $out .= $comboPheno."			</item>";	

$out .= "	<item type='input' width='400' name='parPhenotype' label='Phénotype de la personne' readonly='1' rows='4'/>";
 $out .=  "<item type='button' value='Choix du phénotype' name='choixPhenotype' command='choixPhenotype' />";
$out .= "</item>";
}


$out .= "</item>";

if (isset($utilisateur)){
 	$out .= "<item type='radio' name='typeRecherche' value='analyse' labelWidth='auto' position='label-right' label='Rechercher une analyse'>";
	$out .= "<item type='fieldset' width='450'>";
$out .= "	<item type='input' width='400' name='parPhenotypePersonne' label='Phénotype des personnes à rechercher' readonly='1' rows='4'/>";
 $out .=  "<item type='button' value='Choix du phénotype' name='choixPhenotypePersonne' command='choixPhenotypePersonne' />";
		
	
// 	$out .= "</item>";
	
	
	
	$categorieBiomeds = $CATEGORIEBIOMED_DAO->rechercher_categorie();
	$centres = $CENTRE_DAO->rechercher_centre();

	$out .= "<item type='checkbox' name='prenatal'  id='prenatal'  value='prenatal' labelWidth='auto' position='label-right' label='Prénatal' >";
	$out .= "	<item type='combo' name='categoriePrenatal' width='250' >";
	$out .= "<option value='0' text='Tous les prénataux' selected='true'/>";
	foreach ($categorieBiomeds as $categorieBiomed){
		if ($categorieBiomed->idtypecategorie == 1){
			$out .= "		<option value='".intval($categorieBiomed->idcategorie)."' text='".str_replace ("'", "´", remove_carspeciaux($categorieBiomed->libelle) )."' />";
		}
	}
	$out .= "	</item>";
	$out .= "</item>";

	$out .= "<item type='checkbox' name='postnatal' id='postnatal' value='postnatal' labelWidth='auto' position='label-right' label='Postnatal' >";
	$out .= "	<item type='combo' name='categoriePostnatal' width='250' >";
	$out .= "<option value='0' text='Tous les postnataux' selected='true'/>";
	foreach ($categorieBiomeds as $categorieBiomed){
		if ($categorieBiomed->idtypecategorie == 2){
			$out .= "		<option value='".intval($categorieBiomed->idcategorie)."' text='".str_replace ("'", "´",remove_carspeciaux($categorieBiomed->libelle))."' />";
		}
	}
	$out .= "	</item>";
	$out .= "</item>";

	$out .= "<item type='checkbox' name='foetopat' value='foetopat' id='foetopat' labelWidth='auto' position='label-right' label='Foetopathologie' >";
	$out .= "	<item type='combo' name='categorieFoeto' width='250'>";
	$out .= "<option value='0' text='Toutes les foetopathologies' selected='true'/>";
	foreach ($categorieBiomeds as $categorieBiomed){
		if ($categorieBiomed->idtypecategorie == 3){
			$out .= "		<option value='".intval($categorieBiomed->idcategorie)."' text='".str_replace ("'", "´", remove_carspeciaux($categorieBiomed->libelle))."' />";
		}
	}
	$out .= "	</item>";
	$out .= "</item>";

	$out .= "	<item type='combo' name='parCentre' label='Provenant du centre'>";
	$out .= "<option value='0' text='Tous les centres' selected='true'/>";
	foreach ($centres as $centre){
			$out .= "		<option value='".intval($centre->idcentre)."' text='".str_replace ("'", "´", remove_carspeciaux($centre->nom))."' />";
	}

	$out .= "	</item>";


 	$out .= "</item>";
 	$out .= "</item>";
 }
 $out .=  "<item type='button' value='Rechercher' name='rechercher' command='rechercher' />";
 $out .= "</items>";
print($out);
?>